<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* const s1 = new Set();
      s1.add(1);
      s1.add(1);
      s1.add(2);
      s1.add(+0);
      s1.add(-0);
      console.log(s1.has(1));
      console.log(s1.delete(2)); // 返回是否删除成功
      console.log(s1); */

      // set与数组转换
      /* const arr = [1, 2, 3, 43, 1, 23];
      const ret = [...new Set(arr)];
      console.log(ret); */

      // 字符串去重
      /* const str = "11aabb";
      const ret1 = [...new Set(str)].join("");
      console.log(ret1); */

      // 遍历
      const set = new Set([1, 3, 43, 12]);
      for (const s of set) {
        console.log(s);
      }
      set.forEach((item, index, s) => {
        console.log(item, index, s);
      });
    </script>
  </body>
</html>
